<template>
	<view>
		<view class="topnum">
			<view class="name">{{name}}</view>
			<view class="">{{money}}</view>
		</view>
		<view class="facility">
			<view class="facility_top" @click="$fun.jump(`/pages/equipment/equipment`)">
				<view class="left">
					<view class="line"></view>
					<view class="">兑换{{name}}</view>
				</view>
			</view>
			<view class="inputnum">
				<input type="digit" v-model="num" placeholder="0.00" placeholder-class="inclass" />
				<view class="text" @click="num=beanmoney">最大</view>
			</view>
			<view class="intext">火豆余额:{{beanmoney}} <span
					style="margin-left: 20rpx;">{{fire_exchange_recover}}火豆=1复原值</span> </view>
		</view>
		<view class="btn" @click="$u.throttle(exchangeRecover, 500)">立即兑换</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				money: 0,
				num: '',
				fire_exchange_recover: '',
				beanmoney: 0,
				name: ''
			}
		},
		onLoad(option) {
			this.fire_exchange_recover = option.fire_exchange_recover
			this.name = option.name
			uni.setNavigationBarTitle({
				title: option.name
			})
			//复原
			this.$fun.ajax.post('config/recharge', {
				id: option.id,
				type: option.type
			}).then(res => {
				this.money = res.data.money
			})
			//火豆
			this.$fun.ajax.post('config/recharge', {
				id: 4,
				type: option.type
			}).then(res => {
				this.beanmoney = res.data.money
			})
		},
		methods: {
			exchangeRecover() {
				this.$fun.ajax.post('butt/exchangeRecover', {
					money: this.num
				}).then(res => {
					if (res.code == 1) {
						this.$fun.msg(res.msg)
						this.$fun.jump('', 4, 1200)
					} else {
						this.$fun.msg(res.msg)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F5F1EE;
	}

	.topnum {
		width: 690rpx;
		height: 152rpx;
		background: rgba(255, 255, 255, 0.9);
		border-radius: 24rpx;
		font-weight: 500;
		font-size: 48rpx;
		color: #333333;
		text-align: center;
		margin: 20rpx auto;
		padding: 30rpx 0;

		.name {
			font-weight: 500;
			font-size: 24rpx;
			color: #333333;
			margin-bottom: 10rpx;
		}
	}

	.facility {
		width: 690rpx;
		height: 258rpx;
		background: #FFFFFF;
		border-radius: 24rpx;
		margin: 0 auto;

		&_top {
			display: flex;
			justify-content: space-between;
			height: 88rpx;
			align-items: center;

			.left {
				font-weight: 600;
				font-size: 28rpx;
				color: #333333;
				display: flex;
				align-items: center;

				.line {
					width: 8rpx;
					height: 28rpx;
					background: #5990FF;
					margin-right: 22rpx;
				}
			}

			image {
				width: 48rpx;
				height: 48rpx;
			}
		}

		.inputnum {
			margin: 20rpx 30rpx 0;
			border-bottom: 1rpx solid #666666;
			padding-bottom: 20rpx;
			display: flex;
			justify-content: space-between;

			.text {
				font-weight: 500;
				font-size: 32rpx;
				color: #5990FF;
			}
		}

		.inclass {
			font-weight: 500;
			font-size: 48rpx;
			color: #CCCCCC;
		}

		.intext {
			font-weight: 400;
			font-size: 24rpx;
			color: #999999;
			margin: 20rpx 30rpx;
		}
	}

	.btn {
		font-weight: 500;
		font-size: 32rpx;
		color: #FFFFFF;
		width: 690rpx;
		height: 88rpx;
		background: rgba(0, 170, 255, 0.9);
		border-radius: 44rpx;
		line-height: 88rpx;
		text-align: center;
		margin: 90rpx auto;
	}
</style>